<template>
  <div>
    <table>
      <LianxiTwo
        v-for="(item, index) in goodsArr"
        :key="index"
        :obj="item"
        @add="item.count = $event - 0"
      ></LianxiTwo>
    </table>
    <p>总数量:{{ total }}</p>
  </div>
</template>

<script>
import LianxiTwo from "./components/LianxiTwo.vue";
export default {
  components: {
    LianxiTwo,
  },
  props: {},
  data() {
    return {
      goodsArr: [
        {
          count: 0,
          goodsName: "Watermelon",
        },
        {
          count: 0,
          goodsName: "Banana",
        },
        {
          count: 0,
          goodsName: "Orange",
        },
        {
          count: 0,
          goodsName: "Pineapple",
        },
        {
          count: 0,
          goodsName: "Strawberry",
        },
      ],
    };
  },
  computed: {
    total() {
      return this.goodsArr.reduce((num, item) => num + item.count, 0);
    },
  },
  watch: {},
  created() {},
  methods: {},
};
</script>

<style scoped></style>
